package com.cy.pj.sys.controller;

import com.cy.pj.common.annotation.RequiredLog;
import com.cy.pj.common.bo.PageObject;
import com.cy.pj.common.vo.JsonResult;
import com.cy.pj.sys.entity.SysLog;
import com.cy.pj.sys.service.SysLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;

@Controller
@RequestMapping("/log/")
public class SysLogController {

	@Autowired
	private SysLogService sysLogService;
	private String prefix = "sys";

	@RequiresPermissions("sys:logs:view")
	@GetMapping("/log_list")
	@RequiredLog
	public String logview()
	{
		return prefix + "/log_list";
	}


	@RequiresPermissions("sys:logs:delete")
	@RequestMapping("doDeleteObjects")
	@ResponseBody
	@RequiredLog
	public JsonResult doDeleteObjects(Integer...ids) {

		System.out.println(Arrays.toString(ids));
		//调用业务层方法执行删除业务
		sysLogService.deleteObjects(ids);
		return new JsonResult("delete ok");
	}

	@RequiresPermissions("sys:logs:list")
	@RequestMapping("doFindPageObjects")
	@ResponseBody
	@RequiredLog
	public JsonResult doFindPageObjects(String username,
			Integer pageCurrent){
		PageObject<SysLog> pageObject=
		sysLogService.findPageObjects(username, pageCurrent);
		return new JsonResult(pageObject);//DispatcherServlet
	}

}








